<template>
  <div class="container">
    <div class="box">
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
    </div>
  </div>
</template>

<script setup lang="ts"></script>

<style lang="scss" scoped>
$radius: 0px; //圆角度数
$imgUrl: url(https://w.wallhaven.cc/full/57/wallhaven-572k81.png); //图片地址
.container {
  width: 100%;
  height: 100%;
  border-radius: 4px;
  background: var(--BlockBgColor);
  box-sizing: border-box;
  padding-top: 10px;
  transition: background 0.3s var(--n-bezier);
  font-size: 50px;
  color: var(--TextColor);
  @include center;
  .box {
    width: 500px;
    height: 400px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);

    .item {
      transition: 0.5s;
      background-size: 500px 400px;
      background-image: $imgUrl;
      background-repeat: no-repeat;
      position: relative;
      top: 20px;
      background-position-y: -270px;

      &:nth-child(3n + 1) {
        left: -20px;
        background-position-x: 0;
      }
      &:nth-child(3n + 2) {
        left: 0;
        background-position-x: -170px;
      }
      &:nth-child(3n) {
        left: 20px;
        background-position-x: -335px;
      }
      &:nth-child(-n + 6) {
        top: 0;
        background-position-y: -135px;
      }
      &:nth-child(-n + 3) {
        top: -20px;
        background-position-y: 0;
      }
    }
    &:hover .item {
      top: 0;
      left: 0;
    }
    &:hover .item:nth-child(1) {
      border-top-left-radius: $radius;
    }
    &:hover .item:nth-child(3) {
      border-top-right-radius: $radius;
    }
    &:hover .item:nth-child(7) {
      border-bottom-left-radius: $radius;
    }
    &:hover .item:nth-child(9) {
      border-bottom-right-radius: $radius;
    }
  }
}
</style>
